package com.adhere.system.service.impl;

import com.adhere.system.mapper.RbacRolePrivilegeMapper;
import com.adhere.system.service.IRbacRolePrivilegeService;
import com.adhere.system.pojo.RbacRolePrivilege;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2021-04-02
 */
@Service
public class RbacRolePrivilegeServiceImpl extends ServiceImpl<RbacRolePrivilegeMapper, RbacRolePrivilege> implements IRbacRolePrivilegeService {

    @Autowired
    RbacRolePrivilegeMapper rolePrivilegeMapper;

    @Override
    public void deleteByRoleCode(String roleCode) {
        QueryWrapper<RbacRolePrivilege> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("role_code", roleCode);
        rolePrivilegeMapper.delete(queryWrapper);
    }

    @Override
    public List<RbacRolePrivilege> selectByPrivilegeCode(String privilegeCode) {
        QueryWrapper<RbacRolePrivilege> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("privilege_code", privilegeCode);
        return rolePrivilegeMapper.selectList(queryWrapper);
    }

}
